<template>
    <div class="section">
        <el-descriptions title="老人信息" class="offset">
            <el-descriptions-item label="档案号">{{userData.userNum}}</el-descriptions-item>
            <el-descriptions-item label="老人姓名">{{userData.name}}</el-descriptions-item>
            <el-descriptions-item label="性别">{{userData.gender}}</el-descriptions-item>
            <el-descriptions-item label="证件号">{{userData.identity}}</el-descriptions-item>
            <el-descriptions-item label="入住区域">{{userData.areaNum}}</el-descriptions-item>
            <el-descriptions-item label="入住房间">{{userData.roomnum}}</el-descriptions-item>
            <el-descriptions-item label="床位号">{{userData.number}}</el-descriptions-item>
            <el-descriptions-item label="入院时间">{{userData.inTime}}</el-descriptions-item>
            <el-descriptions-item label="出院时间">{{userData.goawayTime}}</el-descriptions-item>
            <el-descriptions-item label="备注">
            </el-descriptions-item>
        </el-descriptions>
        <el-descriptions title="费用结算" class="offset">
            <el-descriptions-item label="总余额">{{userData.saveMoney}}</el-descriptions-item>
            <el-descriptions-item label="收费金额">{{ calculatedPayMoney }}</el-descriptions-item>
            <el-descriptions-item label="余额">{{userData.resultMoney}}</el-descriptions-item>
            <el-descriptions-item label="住院天数">{{ hospitalDays }}</el-descriptions-item>
            <el-descriptions-item label="结算时间">{{ userData.payTime }}</el-descriptions-item>
        </el-descriptions>
    </div>
</template>

<script>
export default {
    data() {
        return {
            userNum: '',
            userData:{}
        }
    },
    methods: {
     
    },
    created() {
        this.userData = this.$route.query.form;
    },  
    computed: {
    calculatedPayMoney() {
      return this.userData.saveMoney - this.userData.resultMoney;
    },
    hospitalDays() {
      if (this.userData.inTime && this.userData.goAwayTime) {
        const inDate = new Date(this.userData.inTime);
        const outDate = new Date(this.userData.goAwayTime);
        const timeDifference = outDate.getTime() - inDate.getTime();
        const daysDifference = Math.ceil(timeDifference / (1000 * 3600 * 24));
        return daysDifference;
      } else {
        return 0;
      }
    }
    }
}
</script>

<style scoped>
.section {
    width: 1200px;
    height: 200px;
    background-color: white;
    margin-left: 20px;
    margin-top: 25px;
}

.offset {
    margin-top: 30px;
    margin-left: 15px;
}
</style>